from django.db import models

# Create your models here.
from courses.models import Course
from utils.basemodel import BaseModel


class CourseExplain(BaseModel):
    course = models.ForeignKey(
        Course,
        verbose_name="课程",
        on_delete=models.CASCADE,
        related_name="explain"
    )
    expire_time = models.IntegerField(
        verbose_name="有效期",
        default=0,
        help_text="0表示永久有效 30 表示30天有效 60 有60天有效期"
    )
    expire_text = models.CharField(
        verbose_name="有效期描述",
        max_length=100,
    )
    price = models.DecimalField(
        verbose_name="价格",
        max_digits=10,
        decimal_places=2,
        default=0
    )


    class Meta:
        db_table = "course_expire"
        verbose_name = "课程详情"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.course.name + '有效期' + str(self.expire_time) + '天'